using Ln.Fram.SqlSugarCore.Abstractions;
using Ln.Rbac.Domain.Entities;
using Ln.Rbac.Domain.Shared.Enums;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids;

namespace Ln.Rbac.SqlSugarCore.DataSeeds;

public class MenuRuoYiDataSeed //: IDataSeedContributor, ITransientDependency
{
	#region 构造函数
	public MenuRuoYiDataSeed(ISqlSugarRepository<MenuAggregateRoot> repository, IGuidGenerator guidGenerator) => (_repository, _guidGenerator) = (repository, guidGenerator);
	#endregion

	#region 成员属性
	private ISqlSugarRepository<MenuAggregateRoot> _repository;
	private IGuidGenerator _guidGenerator;
	#endregion

	#region 自身方法
	public async Task SeedAsync(DataSeedContext context) { if (!await _repository.IsAnyAsync(x => x.MenuName == "系统管理" && x.MenuSource == MenuSourceEnum.Ruoyi)) await _repository.InsertManyAsync(GetSeedData()); }

	private List<MenuAggregateRoot> GetSeedData()
	{
		List<MenuAggregateRoot> entities = new List<MenuAggregateRoot>();
		Guid system_id = _guidGenerator.Create();
		Guid code_id = _guidGenerator.Create();
		Guid monitor_id = _guidGenerator.Create();
		Guid tool_id = _guidGenerator.Create();
		Guid tenant_id = _guidGenerator.Create();
		Guid user_id = _guidGenerator.Create();
		Guid role_id = _guidGenerator.Create();
		Guid menu_id = _guidGenerator.Create();
		Guid dept_id = _guidGenerator.Create();
		Guid post_id = _guidGenerator.Create();
		Guid dict_id = _guidGenerator.Create();
		Guid config_id = _guidGenerator.Create();
		Guid notice_id = _guidGenerator.Create();
		Guid log_id = _guidGenerator.Create();
		Guid operlog_id = _guidGenerator.Create();
		Guid loginlog_id = _guidGenerator.Create();
		entities.AddRange([
			new MenuAggregateRoot(system_id, Guid.Empty) { MenuName = "系统管理", MenuType = MenuTypeEnum.Catalogue, Router = "/system", IsLink = false, MenuIcon = "system", OrderNum = 100 },
			new MenuAggregateRoot(code_id, Guid.Empty) { MenuName = "代码生成", MenuType = MenuTypeEnum.Catalogue, Router = "/code", IsLink = false, MenuIcon = "build", OrderNum = 91, },
			new MenuAggregateRoot(_guidGenerator.Create(), code_id) { MenuName = "数据表管理", PermissionCode = "code:table:list", MenuType = MenuTypeEnum.Menu, Router = "table", IsLink = false, IsCache = true, Component = "code/table/index", MenuIcon = "online", OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), code_id) { MenuName = "字段管理", PermissionCode = "code:field:list", MenuType = MenuTypeEnum.Menu, Router = "field", IsLink = false, IsCache = true, Component = "code/field/index", MenuIcon = "number", OrderNum = 99 },
			new MenuAggregateRoot(_guidGenerator.Create(), code_id) { MenuName = "模板管理", PermissionCode = "code:template:list", MenuType = MenuTypeEnum.Menu, Router = "template", IsLink = false, IsCache = true, Component = "code/template/index", MenuIcon = "documentation", OrderNum = 98 },
			new MenuAggregateRoot(monitor_id) { MenuName = "系统监控", MenuType = MenuTypeEnum.Catalogue, Router = "/monitor", IsLink = false, MenuIcon = "monitor", OrderNum = 99 },
			new MenuAggregateRoot(_guidGenerator.Create(), monitor_id) { MenuName = "在线用户", PermissionCode = "monitor:online:list", MenuType = MenuTypeEnum.Menu, Router = "online", IsLink = false, IsCache = true, Component = "monitor/online/index", MenuIcon = "online", OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), monitor_id) { MenuName = "缓存列表", PermissionCode = "monitor:cache:list", MenuType = MenuTypeEnum.Menu, Router = "cacheList", IsLink = false, IsCache = true, Component = "monitor/cache/list", MenuIcon = "redis-list", OrderNum = 99 },
			new MenuAggregateRoot(_guidGenerator.Create(), monitor_id) { MenuName = "服务监控", PermissionCode = "monitor:server:list", MenuType = MenuTypeEnum.Menu, Router = "server", IsLink = false, IsCache = true, Component = "monitor/server/index", MenuIcon = "server", OrderNum = 98 },
			new MenuAggregateRoot(_guidGenerator.Create(), monitor_id) { MenuName = "定时任务", PermissionCode = "monitor:job:list", MenuType = MenuTypeEnum.Menu, Router = "job", IsLink = false, IsCache = true, Component = "monitor/job/index", MenuIcon = "job", OrderNum = 97 },
			new MenuAggregateRoot(tool_id) { MenuName = "系统工具", MenuType = MenuTypeEnum.Catalogue, Router = "/tool", IsLink = false, MenuIcon = "tool", OrderNum = 98 },
			new MenuAggregateRoot(_guidGenerator.Create(), tool_id) { MenuName = "接口文档", MenuType = MenuTypeEnum.Menu, Router = "http://localhost:19001/swagger", IsLink = true, MenuIcon = "list", OrderNum = 100, },
			new MenuAggregateRoot(_guidGenerator.Create(), tool_id) { MenuName = "表单生成器", MenuType = MenuTypeEnum.Menu, Router = "build", IsLink = false, MenuIcon = "form", Component = "tool/build/index", IsCache = true, OrderNum = 101, },
			new MenuAggregateRoot(tenant_id, system_id) { MenuName = "租户管理", PermissionCode = "system:tenant:list", MenuType = MenuTypeEnum.Menu, Router = "tenant", IsLink = false, IsCache = true, Component = "system/tenant/index", MenuIcon = "list", OrderNum = 101 },
			new MenuAggregateRoot(_guidGenerator.Create(), tenant_id) { MenuName = "租户查询", PermissionCode = "system:tenant:query", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), tenant_id) { MenuName = "租户新增", PermissionCode = "system:tenant:add", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), tenant_id) { MenuName = "租户修改", PermissionCode = "system:tenant:edit", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), tenant_id) { MenuName = "租户删除", PermissionCode = "system:tenant:remove", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(user_id, system_id) { MenuName = "用户管理", PermissionCode = "system:user:list", MenuType = MenuTypeEnum.Menu, Router = "user", IsLink = false, IsCache = true, Component = "system/user/index", MenuIcon = "user", OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), user_id) { MenuName = "用户查询", PermissionCode = "system:user:query", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), user_id) { MenuName = "用户新增", PermissionCode = "system:user:add", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), user_id) { MenuName = "用户修改", PermissionCode = "system:user:edit", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), user_id) { MenuName = "用户删除", PermissionCode = "system:user:remove", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), user_id) { MenuName = "重置密码", PermissionCode = "system:user:resetPwd", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(role_id, system_id) { MenuName = "角色管理", PermissionCode = "system:role:list", MenuType = MenuTypeEnum.Menu, Router = "role", IsLink = false, IsCache = true, Component = "system/role/index", MenuIcon = "peoples", OrderNum = 99 },
			new MenuAggregateRoot(_guidGenerator.Create(), role_id) { MenuName = "角色查询", PermissionCode = "system:role:query", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), role_id) { MenuName = "角色新增", PermissionCode = "system:role:add", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), role_id) { MenuName = "角色修改", PermissionCode = "system:role:edit", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), role_id) { MenuName = "角色删除", PermissionCode = "system:role:remove", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(menu_id, system_id) { MenuName = "菜单管理", PermissionCode = "system:menu:list", MenuType = MenuTypeEnum.Menu, Router = "menu", IsLink = false, IsCache = true, Component = "system/menu/index", MenuIcon = "tree-table", OrderNum = 98 },
			new MenuAggregateRoot(_guidGenerator.Create(), menu_id) { MenuName = "菜单查询", PermissionCode = "system:menu:query", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), menu_id) { MenuName = "菜单新增", PermissionCode = "system:menu:add", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), menu_id) { MenuName = "菜单修改", PermissionCode = "system:menu:edit", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), menu_id) { MenuName = "菜单删除", PermissionCode = "system:menu:remove", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(dept_id, system_id) { MenuName = "部门管理", PermissionCode = "system:dept:list", MenuType = MenuTypeEnum.Menu, Router = "dept", IsLink = false, IsCache = true, Component = "system/dept/index", MenuIcon = "tree", OrderNum = 97 },
			new MenuAggregateRoot(_guidGenerator.Create(), dept_id) { MenuName = "部门查询", PermissionCode = "system:dept:query", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), dept_id) { MenuName = "部门新增", PermissionCode = "system:dept:add", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), dept_id) { MenuName = "部门修改", PermissionCode = "system:dept:edit", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), dept_id) { MenuName = "部门删除", PermissionCode = "system:dept:remove", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(post_id, system_id) { MenuName = "岗位管理", PermissionCode = "system:post:list", MenuType = MenuTypeEnum.Menu, Router = "post", IsLink = false, IsCache = true, Component = "system/post/index", MenuIcon = "post", OrderNum = 96 },
			new MenuAggregateRoot(_guidGenerator.Create(), post_id) { MenuName = "岗位查询", PermissionCode = "system:post:query", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), post_id) { MenuName = "岗位新增", PermissionCode = "system:post:add", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), post_id) { MenuName = "岗位修改", PermissionCode = "system:post:edit", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), post_id) { MenuName = "岗位删除", PermissionCode = "system:post:remove", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(dict_id, system_id) { MenuName = "字典管理", PermissionCode = "system:dict:list", MenuType = MenuTypeEnum.Menu, Router = "dict", IsLink = false, IsCache = true, Component = "system/dict/index", MenuIcon = "dict", OrderNum = 95 },
			new MenuAggregateRoot(_guidGenerator.Create(), dict_id) { MenuName = "字典查询", PermissionCode = "system:dict:query", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), dict_id) { MenuName = "字典新增", PermissionCode = "system:dict:add", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), dict_id) { MenuName = "字典修改", PermissionCode = "system:dict:edit", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), dict_id) { MenuName = "字典删除", PermissionCode = "system:dict:remove", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(config_id, system_id) { MenuName = "参数设置", PermissionCode = "system:config:list", MenuType = MenuTypeEnum.Menu, Router = "config", IsLink = false, IsCache = true, Component = "system/config/index", MenuIcon = "edit", OrderNum = 94 },
			new MenuAggregateRoot(_guidGenerator.Create(), config_id) { MenuName = "参数查询", PermissionCode = "system:config:query", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), config_id) { MenuName = "参数新增", PermissionCode = "system:config:add", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), config_id) { MenuName = "参数修改", PermissionCode = "system:config:edit", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), config_id) { MenuName = "参数删除", PermissionCode = "system:config:remove", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(notice_id, system_id) { MenuName = "通知公告", PermissionCode = "system:notice:list", MenuType = MenuTypeEnum.Menu, Router = "notice", IsLink = false, IsCache = true, Component = "system/notice/index", MenuIcon = "message", OrderNum = 93 },
			new MenuAggregateRoot(_guidGenerator.Create(), notice_id) { MenuName = "通知查询", PermissionCode = "system:notice:query", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), notice_id) { MenuName = "通知新增", PermissionCode = "system:notice:add", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), notice_id) { MenuName = "通知修改", PermissionCode = "system:notice:edit", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), notice_id) { MenuName = "通知删除", PermissionCode = "system:notice:remove", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(log_id, system_id) { MenuName = "日志管理", MenuType = MenuTypeEnum.Catalogue, Router = "log", IsLink = false, MenuIcon = "log", OrderNum = 92 },
			new MenuAggregateRoot(operlog_id, log_id) { MenuName = "操作日志", PermissionCode = "monitor:operlog:list", MenuType = MenuTypeEnum.Menu, Router = "operlog", IsLink = false, IsCache = true, Component = "monitor/operlog/index", MenuIcon = "form", OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), operlog_id) { MenuName = "操作查询", PermissionCode = "monitor:operlog:query", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), operlog_id) { MenuName = "操作删除", PermissionCode = "monitor:operlog:remove", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(loginlog_id, log_id) { MenuName = "登录日志", PermissionCode = "monitor:logininfor:list", MenuType = MenuTypeEnum.Menu, Router = "logininfor", IsLink = false, IsCache = true, Component = "monitor/logininfor/index", MenuIcon = "logininfor", OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), loginlog_id) { MenuName = "登录查询", PermissionCode = "monitor:logininfor:query", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
			new MenuAggregateRoot(_guidGenerator.Create(), loginlog_id) { MenuName = "登录删除", PermissionCode = "monitor:logininfor:remove", MenuType = MenuTypeEnum.Component, OrderNum = 100 },
		]);
		return entities;
	}
	#endregion
}
